import importlib
def get_control_params(question_name, postfix, cluster_num, guid_w, seed=123):
    if isinstance(question_name, int):
        print("question_name 来自PSFD数据集")
        user_defined= False
        project_name=f"{question_name}"
        project_name=f"{project_name}{postfix}c{cluster_num}w{guid_w}s{seed}"
        return {"user_defined":user_defined,
            "question_name":question_name,
            "postfix":postfix,
            "cluster_num":cluster_num,
            "guid_w":guid_w,
            "project_name": project_name,
            "i_from_psfd": question_name,
            "seed":seed}
    else:
        print(f"question_name 来自用户定义的问题 {question_name}")
        user_defined= True
        module = importlib.import_module(f"DDPM.Evaluation.逆向设计问题.{question_name}")
        project_name = getattr(module, 'project_name')
        project_name=f"{project_name}{postfix}c{cluster_num}w{guid_w}s{seed}"
        t_array_target=getattr(module, 't_array_target')
        p_array_target=getattr(module, 'p_array_target')
        cstar = getattr(module, 'cstar')
        rho=getattr(module, 'rho')
        n = getattr(module, 'n')
        At = getattr(module, 'At')
        return {"user_defined":user_defined,
                "question_name":question_name,
                "postfix":postfix,
                "cluster_num":cluster_num,
                "guid_w":guid_w,
                "project_name": project_name,
                "t_array_target": t_array_target,
                "p_array_target": p_array_target,
                "cstar": cstar,
                "rho": rho,
                "n": n,
                "At": At,
                "seed":seed}

if __name__ == "__main__":
    control_params=get_control_params(question_name="K正弦状燃面装药",
                 postfix="_epoch50000",
                 cluster_num=5,
                 guid_w=0.5)
    #control_params=get_control_params(question_name=2980,
    #             postfix="_epoch50000",
    #             cluster_num=5,
    #             guid_w=0.5)
    print(control_params)